package com.carlinfo.stu_ques.users.dao.impl;

import java.io.File;
import com.carlinfo.stu_ques.common.dao.impl.BaseDaoImpl;
import com.carlinfo.stu_ques.users.dao.ILevelDao;
import com.carlinfo.stu_ques.users.pojo.Level;

public class LevelDaoImpl extends BaseDaoImpl<Level> implements ILevelDao
{
	private File file = new File(this.parentFile, "levelSource.dat");

	/**
	 * 无参的构造函数，在实例化对象的时候先把文件读出来
	 */
	public LevelDaoImpl()
	{
		this.readFile(file);
	}

	@Override
	public int saveOneDao(Level e)
	{
		e.setId(this.id);
		tempId = e.getId();
		super.saveOneDao(e);
		this.writeFile(file);
		return e.getId();
	}

	@Override
	public void updateOneDao(Level e)
	{
		tempId = e.getId();
		super.updateOneDao(e);
		this.writeFile(file);
	}

	@Override
	public void deleteOneDao(Level e)
	{
		this.tempId = e.getId();
		super.deleteOneDao(e);
		this.writeFile(file);
	}

}
